import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { OrderService } from './order.service';
import { CreateCartOrderDto, CreateDirectOrderDto, QueryOrder } from './dto/order.dto';
import { User } from 'src/module/system/user/user.decorator';

@Controller('shop/order')
export class OrderController {
  constructor(private readonly orderService: OrderService) {}

  @Post('cart')
  buyCart(@Body() dto: CreateCartOrderDto, @User() user: Record<string, any>) {
    return this.orderService.createCartOrder(user.id, dto);
  }

  @Post('buy')
  buyNow(@Body() dto: CreateDirectOrderDto, @User() user: Record<string, any>) {
    return this.orderService.createDirectOrder(user.id, dto);
  }

  @Get()
  orderList(@Query() dto: QueryOrder, @User() user: Record<string, any>) {
    return this.orderService.orderList(user.id, dto);
  }
}
